var slider = new Array();
var timerSlider = new Array();
var prevVidState = new Array();

function sliderInit(slot) {
	slider[slot] = $("#vid-"+slot+"-slider").slider({
		handle: ".vid-slider-pos-handle",
		change: function(e,ui) { 
			if (ui.value==50) { printLog(50); }
			sliderTimer(slot);
		},
		start: function(e,ui) {
			prevVidState[slot] = vidState[slot];
			vidState[slot] = 6;
			if (ui.value==50) { printLog(50); }
			timerSlider[slot] = setInterval("sliderTimer("+slot+")", 500);
		},
		stop: function(e,ui) {
			vidState[slot] = prevVidState[slot];
			if (ui.value==50) { printLog(50); }
			clearInterval(timerSlider[slot]);
		}
	});
}

function sliderTimer(slot) {
	sliderValue = slider[slot].slider("value");
	videoGotoPerc(sliderValue, slot);
}

function setSliderSlider(perc, slot) {
	//printLog('Set position slider '+slot+' to value: '+perc);
	$("#vid-"+slot+"-slider .vid-slider-pos-handle").css("left", (perc*1.3) + "px");
}

function updateSliderSlider(slot) {
	setSliderSlider(vid[slot].getCurrentTime() / vid[slot].getDuration() * 100, slot);
}

function updateBufferSlider(slot) {
	loaded = ((vid[slot].getVideoStartBytes() + vid[slot].getVideoBytesLoaded()) / vid[slot].getVideoBytesTotal()) * 100;
	$("#vid-"+slot+"-slider .vid-slider-load").css("width", (loaded*1.47) + "px");
	//printLog('Video in slot ' + i + ' loaded state: '+loaded+'%');
}